package com.zhou.common.pub.util.pwd;

/**
 * @author xianfeng
 * @date 2023/9/20 17:22
 */
public class CharacterRule {

    /**
     * 字符集对象
     */
    protected final CharacterData characterData;

    /**
     * 最少需要的字符数量
     */
    protected int numCharacters = 1;

    public CharacterRule(final CharacterData data) {
        this(data, 1);
    }

    public CharacterRule(final CharacterData data, final int num) {
        setNumberOfCharacters(num);
        characterData = data;
    }

    public void setNumberOfCharacters(final int n) {
        if (n > 0) {
            numCharacters = n;
        } else {
            throw new IllegalArgumentException("argument must be greater than zero");
        }
    }

    public String getValidCharacters() {
        return characterData.getCharacters();
    }

    public int getNumberOfCharacters() {
        return numCharacters;
    }
}
